import { createApp } from "vue";
// 样式
import "@/assets/css/styles.css";
import "nprogress/nprogress.css";
import "./permission";
import btnPermissions from "./btnPermission";
import App from "./App.vue";
// 路由
import router from "@/router";
import { generateRouter } from "@/router";
// 状态
import store from "@/store";
// ui库
import ElementPlus from "element-plus";
// import 'element-plus/dist/index.css'
import "@/assets/css/element/index.scss";

//图标
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

const app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

// i18n
import i18n from "@/locales";
//权限验证

app.use(store);

app.directive("btn", {
  mounted(el, binding) {
    btnPermissions(el, binding);
  },
});

const boot = async () => {
  await generateRouter();
  app.use(ElementPlus);
  app.use(i18n);
  app.use(router);
  app.mount("#app");
};
boot();
